<template>
  <ul>
<!--    <li >-->
      <div class="skeleton" v-show="newsList.length == 0" v-for="num in number" :key="num">
        <a-spin tip="Loading...">
          <div class="spin-content">
            新闻正在载入。。。
          </div>
        </a-spin>
      </div>
<!--    </li>-->
    <li v-for="item in newsList" :key="item.articleId" @click="toDetail(item.articleId)">
      <div>
        <div>{{ item.title }}</div>
        <span>{{item.articleSource}}</span>
        <span>{{item.createTime}}</span>
      </div>
      <img :src="item.imgList" alt="">
    </li>
  </ul>

</template>

<script>
export default {
  name: "newsLi",
  data(){
    return {
      number:10
    }
  },
  methods:{
    toDetail(articleId){
      sessionStorage.removeItem('value')
      this.$router.push({path:'/detail',query:{articleId:articleId}})
    }
  },
  props: {
    newsList: Array
  },
  created() {
    this.number = Number(sessionStorage.getItem('num'))
  },

}
</script>

<style scoped lang="less">
ul {

  >li {
    padding: 5px 15px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    > div {
      width: calc(100% - 135px);
      > div {
        font-size: 18px;
        margin-bottom: 8px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        height: 58px;
        line-height: 30px;
      }
      > span:nth-of-type(1) {
        font-size: 14px;
        display: inline-block;
        width: calc(100% - 75px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: 700;
        color: red;
      }
      > span:nth-of-type(2) {
        font-size: 14px;
        display: inline-block;
        width: 75px;
        white-space: nowrap;
        overflow: hidden;
        float: right;
        color: #938d8d;
      }
    }
    >img{
      height: 90px;
      width: 125px;
    }
  }
}
.skeleton {

  div {
    height: 135px!important;

  }
}
.spin-content {
  border: 1px solid #91d5ff;
  background-color: #e6f7ff;
  padding: 30px;
}
/deep/.ant-spin-nested-loading > div > .ant-spin {
  z-index: 1;
}
</style>